package com.hxexp.weixin.test;

import java.util.ArrayList;
import java.util.List;

import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;

import com.hxexp.weixin.common.cache.PassengerCacheManager;
import com.hxexp.weixin.hpe.api.passengerlist.model.PassengerBean;
import com.hxexp.weixin.test.runner.JUnit4WithSpringLogClassRunner;

/**
 * 乘车人信息缓存管理器实现类型测试
 *
 * @author wang.bin
 *
 */
@RunWith(JUnit4WithSpringLogClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@ContextConfiguration(locations = { "classpath:conf/spring/spring-biz.xml", "classpath:conf/spring/spring-ehcache.xml" })
public class PassengersCacheManagerTester {

    @Autowired
    private PassengerCacheManager passengerCacheManager;

    private static PassengerBean passenger = new PassengerBean();
    private static PassengerBean passenger1 = new PassengerBean();

    @Test
    public void testCase01() {
        passenger.setPassengerId("1");
        passenger.setUserId("11");
        passenger.setFullname("wb");
        passenger.setMobile("13688887777");
        passenger.setGender("2");
        passengerCacheManager.put("1", passenger);
    }

    @Test
    public void testCase02() {
        List<PassengerBean> list = new ArrayList<PassengerBean>();
        passenger.setPassengerId("1");
        passenger.setUserId("11");
        passenger.setFullname("wb");
        passenger.setMobile("13688887777");
        passenger.setGender("2");

        passenger1.setPassengerId("2");
        passenger1.setUserId("11");
        passenger1.setFullname("www");
        passenger1.setMobile("13699998876");
        passenger1.setGender("2");
        list.add(passenger);
        list.add(passenger1);
        passengerCacheManager.batchPut("11", list);
    }

    @Test
    public void testCase03() {
        PassengerBean passenger = passengerCacheManager.get("2");
        Assert.assertEquals(passenger1, passenger);
    }
}
